package com.pet.dto;

import com.pet.enums.StatusCodeEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result implements Serializable {
    /**
     * 状态码
     */
    private int code;
    /**
     * 信息
     */
    private String msg;
    /**
     * 数据
     */
    private Object data;

    public static final int SUCCESS = 0;
    public static final int ERROR = -1;

    public static Result result(int code, String msg, Object data) {
        return new Result(code, msg, data);
    }

    public static Result result(int code, String msg) {
        return new Result(code, msg, null);
    }

    public static Result success(Object data) {
        return result(SUCCESS, "success", data);
    }

    public static Result success() {
        return result(SUCCESS, "success", null);
    }

    public static Result error(String msg) {
        return result(ERROR, msg, null);
    }
}
